package com.dqk.demo.controller;

import com.dqk.demo.repository.GirlRepository;
import com.dqk.demo.entity.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class GirlController {

    @Autowired
    private GirlRepository girlRepository;

    @GetMapping(value = "girls")
    public List<UserInfo> getList(){
        return girlRepository.findAll();
    }

    @PostMapping(value = "girls")
    public String add(Integer id,String cupSize,Integer age){
        UserInfo userInfo = new UserInfo();
        userInfo.setId(id);
        userInfo.setCupSize(cupSize);
        userInfo.setAge(age);
        girlRepository.save(userInfo);
        return "success";
    }

}
